package com.crimsec.utils.snmp.model.dao;

import java.io.IOException;
import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;
import javax.persistence.PersistenceException;

/**
 *
 * @author moroz
 */
public abstract class AbstractDAO {

    public static void save(Object entity, EntityManager em) throws IOException {
        EntityTransaction tx = em.getTransaction();
        try {
            tx.begin();
            em.persist(entity);
            tx.commit();
        } catch (PersistenceException e) {
            tx.rollback();
            throw new IOException(e.getMessage(), e);
        }

    }
}
